//package com.pactera.asmp.server.service;
//
//import com.atlassian.jira.rest.client.api.JiraRestClient;
//import com.atlassian.jira.rest.client.api.JiraRestClientFactory;
//import com.atlassian.jira.rest.client.api.domain.Issue;
//import com.atlassian.jira.rest.client.api.domain.input.FieldInput;
//import com.atlassian.jira.rest.client.api.domain.input.IssueInput;
//import com.atlassian.jira.rest.client.api.domain.input.IssueInputBuilder;
//import com.atlassian.jira.rest.client.internal.async.AsynchronousJiraRestClientFactory;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.stereotype.Service;
//
//import java.io.IOException;
//import java.net.URI;
//import java.net.URISyntaxException;
//import java.util.Collections;
//
//@Service
//public class JiraService {
//
//    @Value("${jira.base-url}")
//    private String jiraBaseUrl;
//
//    @Value("${jira.username}")
//    private String jiraUsername;
//
//    @Value("${jira.api-token}")
//    private String jiraApiToken;
//
//    @Value("${jira.project-key}")
//    private String projectKey;
//
//    @Value("${jira.issue-type-id}")
//    private Long issueTypeId;
//
//    /**
//     * 创建一个 JIRA 问题
//     *
//     * @param summary     问题摘要
//     * @param description 问题描述
//     * @return 创建的问题对象
//     */
//    public Issue createIssue(String jiraBaseUrl ,String summary, String description, String jiraUsername, String jiraPassword) {
//        try {
//        // 1. 构建Jira客户端连接
//        JiraRestClientFactory factory = new AsynchronousJiraRestClientFactory();
//        URI jiraUri = new URI(jiraBaseUrl);
//        JiraRestClient restClient = factory.createWithBasicHttpAuthentication(jiraUri, jiraUsername, jiraPassword);
//
//        // 2. 组装Issue参数（标题、描述、项目、类型必传，其他字段按需加）
//        IssueInput issueInput = new IssueInputBuilder()
////                .setProjectKey("PROJECT_KEY")
//                .setIssueTypeId(2l)
//                .setSummary(summary) // 问题标题
//                .setDescription(description) // 问题描述
//                .setReporterName(jiraUsername) // 报告人
//                .build();
//
//        // 3. 提交创建Issue，返回Issue信息
//        restClient.getIssueClient().createIssue(issueInput).claim();
//        System.out.println("Jira Issue创建成功！");
//
//        // 4. 关闭客户端连接
//
//            restClient.close();
//        } catch (IOException | URISyntaxException e) {
//            e.printStackTrace();
//        }
//        return null;
//    }
//
//}
